package com.dhu.entity;

import com.dhu.enums.ResultCode;
import lombok.Data;

/**
 * @Author gongjiawei
 * @Date 2024/6/14 12:31
 * @注释
 */
@Data
public class Result<T> {

    private boolean success;
    private Integer code;
    private String mssage;
    private T data;

    public static Result ok(){
        Result result=new Result();
        result.setSuccess(true);
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMssage(ResultCode.SUCCESS.getDesc());
        return result;
    }

    public static <T>Result ok(T data){
        Result result=new Result();
        result.setSuccess(true);
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMssage(ResultCode.SUCCESS.getDesc());
        result.setData(data);
        return result;
    }


    public static Result fail(){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(ResultCode.FAIL.getCode());
        result.setMssage(ResultCode.FAIL.getDesc());
        return result;
    }
    public static <T>Result fail(T data){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(ResultCode.FAIL.getCode());
        result.setMssage(ResultCode.FAIL.getDesc());
        result.setData(data);
        return result;
    }
    public static <T>Result fail(Integer code,String message){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(code);
        result.setMssage(message);
        return result;
    }




}
